package net.xiduth.game.player;

import net.xiduth.Settings;
import net.xiduth.game.World;
import net.xiduth.game.npc.NPC;
import net.xiduth.game.player.content.FriendChatsManager;

public class Starter {

	public static final int MAX_STARTER_COUNT = 1;

	public static void appendStarter(Player player) {
		String ip = player.getSession().getIP();
		int count = StarterMap.getSingleton().getCount(ip);
		if (count >= MAX_STARTER_COUNT) {
			return;
		}
		
		if (player.starter == 1) {
			player.getInterfaceManager().sendWelcome();
			player.getInventory().addItem(1856, 1); // Information Book
			player.getInventory().addItem(556, 100); // Air Rune
			player.getInventory().addItem(558, 50); // Mind Rune
			player.getInventory().addItem(1321, 1); // Bronze Scimitar
			player.getInventory().addItem(841, 1); // Shortbow
			player.getInventory().addItem(884, 500); // Iron Arrow
			//player.getInventory().addItem(20821, 1); // Beta sword
			player.setSpins(1);
			player.refreshSqueal();
			player.sendMessage("You are given one Squeal of Fortune spin for joining "
					+ Settings.SERVER_NAME + "!");
			player.getHintIconsManager().removeUnsavedHintIcon();
			player.getMusicsManager().reset();
			FriendChatsManager.joinChat("xiduth", player);
			FriendChatsManager.refreshChat(player);
			player.getCombatDefinitions().setAutoRelatie(true);
			player.getCombatDefinitions().refreshAutoRelatie();
			StarterMap.getSingleton().addIP(ip);
			player.setDoneCombatTutorial();
			player.falseCombatTutorial();
			player.falseSkillsTutorial();
			player.setDoneSkillsTutorial();
			player.getPackets().sendOpenURL(Settings.VOTE_LINK);
			NPC guide = findNPC(7753); 
			if (guide != null)
				player.getHintIconsManager().addHintIcon(guide, 0, -1, false);
		//	player.getDialogueManager().startDialogue("SimpleMessage", "Where the hell am I? Maybe I should talk to the cook over there..");
		}
	}
	public static NPC findNPC(int id) {
		for (NPC npc : World.getNPCs()) {
			if (npc == null || npc.getId() != id)
				continue;
			return npc;
		}
		return null;
	}
}